// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { itemType } from "../../../../script/game/gameType";
import { ListItem } from "../../../../script/util/ListView/ListItem";
import { ccs } from "../../../../script/util/services";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends ListItem<itemType> {
    initItem(data: itemType, index: number) {
        // ccs.spriteExd.setSprite(this.icon.node, ccs.resMgr.getItemIcon(data.icon));
        this.tips.string = data.desc;
        this.title.string = data.name;
        this.price.string = data.price.toString();
        
    }
    onItemclick(data: itemType) {
        cc.log(data);
        ccs.winMgr.showWin("popBuyItem", {id: data.id});
    }

    @property(cc.Label)
    title: cc.Label = null;

    @property(cc.Sprite)
    icon: cc.Sprite = null;

    @property(cc.RichText)
    tips: cc.RichText = null;

    @property(cc.Label)
    price: cc.Label = null;

    start () {

    }

}
